<html>
<head><meta charset="utf-8"><title>NaNs in windows-gnu float arthitmetic · t-compiler/wg-llvm · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/index.html">t-compiler/wg-llvm</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html">NaNs in windows-gnu float arthitmetic</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="178707183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178707183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178707183">(Oct 21 2019 at 22:56)</a>:</h4>
<p>Hey,<br>
Did my best about <a href="https://github.com/rust-lang/rust/issues/53254#issuecomment-544741814" target="_blank" title="https://github.com/rust-lang/rust/issues/53254#issuecomment-544741814">https://github.com/rust-lang/rust/issues/53254#issuecomment-544741814</a> on the Rust side.<br>
How can I reduce it further to report it on LLVM bugzilla?</p>



<a name="178732515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178732515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178732515">(Oct 22 2019 at 08:13)</a>:</h4>
<p>Looks like generated IR is the same apart from the GOT flag. In the backend it seems like everything is also the same up until fpow legalization, where an additional 32-byte call stack adjustment is emitted on pc-windows-gnu.</p>



<a name="178736527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178736527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178736527">(Oct 22 2019 at 09:10)</a>:</h4>
<p>When I replace <code>transmute(0_i64)</code> with <code>__m64(0_i64)</code> all platforms I tested give correct result.<br>
I don't know enough about it but could it be alignment issue?</p>



<a name="178747487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178747487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178747487">(Oct 22 2019 at 11:52)</a>:</h4>
<p>Do you have a godbolt link ready for the verson with <code>__m64(0)</code>?</p>



<a name="178747552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178747552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178747552">(Oct 22 2019 at 11:53)</a>:</h4>
<p>Sure, <a href="https://godbolt.org/z/Hmshca" target="_blank" title="https://godbolt.org/z/Hmshca">https://godbolt.org/z/Hmshca</a></p>



<a name="178747663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178747663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178747663">(Oct 22 2019 at 11:54)</a>:</h4>
<p>So that doesn't use any MMX instructions. It just does a 64b scalar store to the stack (<code>x86_mmx</code>-typed) stack slot</p>



<a name="178747669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178747669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178747669">(Oct 22 2019 at 11:54)</a>:</h4>
<p>More evidence that the MMX instructions are to blame</p>



<a name="178747702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178747702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178747702">(Oct 22 2019 at 11:55)</a>:</h4>
<p>Ah, it's <code>mm0</code></p>



<a name="178747814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178747814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178747814">(Oct 22 2019 at 11:56)</a>:</h4>
<p>Could be another weird msvcrt issue, I'll see if I can try with ucrt.</p>



<a name="178750570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178750570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178750570">(Oct 22 2019 at 12:32)</a>:</h4>
<blockquote>
<p>Honestly, I think the best fix would be to not use MMX intrinsics ever.</p>
</blockquote>
<p>IIUC, the test programs are not using MMX, but the math library is, right ?</p>



<a name="178750583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178750583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178750583">(Oct 22 2019 at 12:32)</a>:</h4>
<p>Replacing msvcrt with ucrt doesn't help so it must be something else different between msvc and mingw.</p>



<a name="178750603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178750603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178750603">(Oct 22 2019 at 12:33)</a>:</h4>
<p>Ah no, <span class="user-mention" data-user-id="119581">@Mateusz Mikuła</span> example uses <code>pmovmskb</code></p>



<a name="178750712"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178750712" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178750712">(Oct 22 2019 at 12:34)</a>:</h4>
<p>Mingw <code>powf</code> just calls msvcrt pow, have fun guessing what it does internally.<br>
<code>pmovmskb</code> comes from "unwrapped" <code>_mm_movemask_pi8</code></p>



<a name="178750748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178750748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178750748">(Oct 22 2019 at 12:35)</a>:</h4>
<p>The thing is, the problem I reported happens even if you don't use MMX in Rust</p>



<a name="178750763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178750763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178750763">(Oct 22 2019 at 12:35)</a>:</h4>
<p>Your example uses MMX without calling <code>emms</code></p>



<a name="178750785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178750785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178750785">(Oct 22 2019 at 12:35)</a>:</h4>
<p>We know such code doesn't work: <a href="https://github.com/rust-lang/rust/issues/57831" target="_blank" title="https://github.com/rust-lang/rust/issues/57831">https://github.com/rust-lang/rust/issues/57831</a></p>



<a name="178750857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178750857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178750857">(Oct 22 2019 at 12:36)</a>:</h4>
<p>It has UB of the form "calling a function with an incompatible ABI"</p>



<a name="178750868"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178750868" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178750868">(Oct 22 2019 at 12:36)</a>:</h4>
<p>All my code is extraction from corearch and packed_simd.</p>



<a name="178750893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178750893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178750893">(Oct 22 2019 at 12:36)</a>:</h4>
<p>The <code>pmovmskb</code> ? Then that's a bug in <code>packed_simd</code> (<code>packed_simd</code> should call <code>emms</code> when it uses it, or not use MMX at all like <span class="user-mention" data-user-id="124289">@rkruppe</span> suggests)</p>



<a name="178750914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178750914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178750914">(Oct 22 2019 at 12:37)</a>:</h4>
<p>Notice that my original example does not use MMX though</p>



<a name="178750950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178750950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178750950">(Oct 22 2019 at 12:37)</a>:</h4>
<p>So it might be a different issue</p>



<a name="178751055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751055">(Oct 22 2019 at 12:38)</a>:</h4>
<p>Original example has been fixed long time ago, I said it in one of the comments.<br>
<code>pmovmskb</code> came from <a href="https://docs.rs/core_arch/0.1.3/x86_64-unknown-linux-gnu/src/core_arch/x86/sse.rs.html#2396-2398" target="_blank" title="https://docs.rs/core_arch/0.1.3/x86_64-unknown-linux-gnu/src/core_arch/x86/sse.rs.html#2396-2398">https://docs.rs/core_arch/0.1.3/x86_64-unknown-linux-gnu/src/core_arch/x86/sse.rs.html#2396-2398</a></p>



<a name="178751070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751070">(Oct 22 2019 at 12:38)</a>:</h4>
<p>Now where <code>_mm_movemask_pi8</code> did came from...</p>



<a name="178751097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751097">(Oct 22 2019 at 12:39)</a>:</h4>
<p>Ah, I did not got that. I thought that some fix landed on LLVM that did not fix the original example, hence why the issue is still open.</p>



<a name="178751118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751118">(Oct 22 2019 at 12:39)</a>:</h4>
<p>So yeah, that's a different bug.</p>



<a name="178751136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751136">(Oct 22 2019 at 12:39)</a>:</h4>
<p>That code has undefined behavior, and the fix is either not to use MMX or to call emms</p>



<a name="178751256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751256">(Oct 22 2019 at 12:41)</a>:</h4>
<p>calling emms is not a fix tbh</p>



<a name="178751270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751270">(Oct 22 2019 at 12:41)</a>:</h4>
<p>I honestly think stdarch should just kill all the MMX intrinsics</p>



<a name="178751281"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751281" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751281">(Oct 22 2019 at 12:41)</a>:</h4>
<p>Their usefulness was always controversial and they are actually impossible to use correctly</p>



<a name="178751414"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751414" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751414">(Oct 22 2019 at 12:43)</a>:</h4>
<p>They are not stable I think, so we could just do that.</p>



<a name="178751497"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751497" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751497">(Oct 22 2019 at 12:44)</a>:</h4>
<p>The problem is that there is no way for LLVM to generate reasonable codegen for when they are used in packed_simd, but at that point using inline assembly might be a better solution.</p>



<a name="178751537"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751537" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751537">(Oct 22 2019 at 12:44)</a>:</h4>
<p>Why would they be used in packed_simd anyway?</p>



<a name="178751542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751542">(Oct 22 2019 at 12:44)</a>:</h4>
<p>It supports 64-bit wide vectors</p>



<a name="178751545"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751545" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751545">(Oct 22 2019 at 12:44)</a>:</h4>
<p>e.g. f32x2</p>



<a name="178751549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751549">(Oct 22 2019 at 12:44)</a>:</h4>
<p>But why</p>



<a name="178751553"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751553" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751553">(Oct 22 2019 at 12:44)</a>:</h4>
<p>Who uses those</p>



<a name="178751597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751597">(Oct 22 2019 at 12:45)</a>:</h4>
<p>2D code using (x, y)</p>



<a name="178751612"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751612" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751612">(Oct 22 2019 at 12:45)</a>:</h4>
<p>where x and y are f32s</p>



<a name="178751664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751664">(Oct 22 2019 at 12:46)</a>:</h4>
<p>Does such code actually <em>want</em> to use MMX? Does it benefit from it vs scalar code or padding to f32x4?</p>



<a name="178751693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751693">(Oct 22 2019 at 12:46)</a>:</h4>
<p>That code wants to efficiently test whether <code>(x, y) &lt; (z, w)</code> returns <code>(0, 0)</code> or <code>(0xff, 0xff)</code></p>



<a name="178751713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751713">(Oct 22 2019 at 12:47)</a>:</h4>
<p>That doesn't answer my question</p>



<a name="178751714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751714">(Oct 22 2019 at 12:47)</a>:</h4>
<p>the scalar thing was much slower than the <code>pmovmaskb</code> operation, which does it at once</p>



<a name="178751725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751725">(Oct 22 2019 at 12:47)</a>:</h4>
<p>Ok, and what about the SSE equivalent?</p>



<a name="178751782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751782">(Oct 22 2019 at 12:48)</a>:</h4>
<p>because that's what you'd get with <a href="https://github.com/rust-lang/rust/issues/58168" target="_blank" title="https://github.com/rust-lang/rust/issues/58168">https://github.com/rust-lang/rust/issues/58168</a> anyway</p>



<a name="178751798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751798">(Oct 22 2019 at 12:48)</a>:</h4>
<p>what would be the SSE equivalent ?</p>



<a name="178751827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751827">(Oct 22 2019 at 12:49)</a>:</h4>
<p>I don't know <code>pmovmaskb</code> or my SSE intrinsics well enough to tell you that, but I would be extremely surprised if there wasn't a reasonably short instruction sequence for it</p>



<a name="178751851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751851">(Oct 22 2019 at 12:49)</a>:</h4>
<p>the three operations where this is used is the boolean <code>m32x2::{all, any, none}</code> operations where you can just get a mask, and test it - one can build that on top of <code>m32x4</code>, e.g., by using a shuffle to mix in the <code>m32x2</code> with two other elements, and then do the SSE equivlaent</p>



<a name="178751988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178751988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178751988">(Oct 22 2019 at 12:51)</a>:</h4>
<p>e.g. for <code>all</code> you do a <code>shuffle!(m32x2, {true, true});</code>, for none you do a <code>shuffle!(m32x2, {false, false})</code>, etc. and then you follow both by a <code>__mm_movmask_epi8</code> or similar</p>



<a name="178752149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752149">(Oct 22 2019 at 12:53)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> wait.. _mm_movemask_pi8</p>



<a name="178752158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752158">(Oct 22 2019 at 12:53)</a>:</h4>
<p>that's an SSE intrinsic..</p>



<a name="178752242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752242">(Oct 22 2019 at 12:54)</a>:</h4>
<p>but it takes an MMX register as its argument..</p>



<a name="178752306"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752306" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752306">(Oct 22 2019 at 12:54)</a>:</h4>
<p>lol</p>



<a name="178752307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752307">(Oct 22 2019 at 12:54)</a>:</h4>
<p>I guess one can use <code>__mm_movemask_ps</code> instead there by doing the widening</p>



<a name="178752526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752526">(Oct 22 2019 at 12:57)</a>:</h4>
<p>To be clear, you are talking about a future where <code>m32x2</code> is no longer mapped to the <code>x86_mmx</code> type, right? Because if that type is still involves, LLVM will still sometimes use <code>mmN</code> registers, which besides corrupting the x87 stack will cause unnecessary moves between register banks</p>



<a name="178752678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752678">(Oct 22 2019 at 12:59)</a>:</h4>
<p>Although I'm curious whether mapping it to e.g. i64 would be any better for performance.</p>



<a name="178752694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752694">(Oct 22 2019 at 12:59)</a>:</h4>
<p>Let's check what GCC can do</p>



<a name="178752727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752727">(Oct 22 2019 at 12:59)</a>:</h4>
<p><span class="user-mention" data-user-id="124289">@rkruppe</span> <code>m32x2</code> is not mapped to <code>x86_mmx</code> right now</p>



<a name="178752737"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752737" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752737">(Oct 22 2019 at 12:59)</a>:</h4>
<p>It's not?</p>



<a name="178752739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752739">(Oct 22 2019 at 13:00)</a>:</h4>
<p>no</p>



<a name="178752803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752803">(Oct 22 2019 at 13:00)</a>:</h4>
<p>only <code>i64x1</code> is... for some reason..</p>



<a name="178752811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752811">(Oct 22 2019 at 13:00)</a>:</h4>
<p>but <code>packed_simd</code> does not support that type</p>



<a name="178752818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752818">(Oct 22 2019 at 13:00)</a>:</h4>
<p>But f32x2 is, right?</p>



<a name="178752822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752822">(Oct 22 2019 at 13:00)</a>:</h4>
<p>no</p>



<a name="178752836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752836">(Oct 22 2019 at 13:00)</a>:</h4>
<p>only <code>__m64</code> is mapped to <code>x86_mmx</code></p>



<a name="178752856"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752856" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752856">(Oct 22 2019 at 13:00)</a>:</h4>
<p>but that intrinsic happens to use it, so when the <code>transmute</code> happens, the <code>x86_mmx</code> type is used</p>



<a name="178752885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752885">(Oct 22 2019 at 13:01)</a>:</h4>
<p>Oh, does packed_simd only cast to __m64 internally and temporarily</p>



<a name="178752899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752899">(Oct 22 2019 at 13:01)</a>:</h4>
<p>yes</p>



<a name="178752906"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752906" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752906">(Oct 22 2019 at 13:01)</a>:</h4>
<p>because that SSE intrinsic takes an <code>__m64</code></p>



<a name="178752908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752908">(Oct 22 2019 at 13:01)</a>:</h4>
<p>Even better</p>



<a name="178752916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752916">(Oct 22 2019 at 13:01)</a>:</h4>
<p><a href="https://godbolt.org/z/CTv-VG" target="_blank" title="https://godbolt.org/z/CTv-VG">https://godbolt.org/z/CTv-VG</a></p>



<a name="178752933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752933">(Oct 22 2019 at 13:01)</a>:</h4>
<p>so there I use <code>_mm_movemask_ps</code> instead and everything just works nicely</p>



<a name="178752936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752936">(Oct 22 2019 at 13:01)</a>:</h4>
<p>at least for that intrinsic</p>



<a name="178752998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178752998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178752998">(Oct 22 2019 at 13:02)</a>:</h4>
<p>Great</p>



<a name="178753570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178753570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178753570">(Oct 22 2019 at 13:09)</a>:</h4>
<p>For the <code>m32x2::all</code> operation things are a bit different</p>



<a name="178753574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178753574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178753574">(Oct 22 2019 at 13:09)</a>:</h4>
<p><a href="https://godbolt.org/z/X35ZR2" target="_blank" title="https://godbolt.org/z/X35ZR2">https://godbolt.org/z/X35ZR2</a></p>



<a name="178753609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178753609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178753609">(Oct 22 2019 at 13:09)</a>:</h4>
<p>The none and any operation can make use of the fact that, in the calling convention, the 32x2 vector will contain another two zeroed 32x2 elements behind it</p>



<a name="178753749"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178753749" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178753749">(Oct 22 2019 at 13:11)</a>:</h4>
<p>for the all mask there are a couple of things one can do to map the m32x2 into a m32x4, but all of them appear to generate unnecessary instructions, although arguably the MMX code has UB</p>



<a name="178753764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178753764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178753764">(Oct 22 2019 at 13:11)</a>:</h4>
<p>so it is not a fair comparison either</p>



<a name="178753787"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178753787" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178753787">(Oct 22 2019 at 13:12)</a>:</h4>
<p>Now that you mention it, looking at this in isolation might actually be a bit misleading. The calling convention for <code>&lt;float x 2&gt;</code> on x86+SSE targets is pretty funky and in reality you'd probably always have those operations inlined</p>



<a name="178753885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178753885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178753885">(Oct 22 2019 at 13:12)</a>:</h4>
<p>Since you apparently have a concrete use case, a larger snippet that uses the any/all/none operations in a representative way might be more instructive</p>



<a name="178753890"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178753890" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178753890">(Oct 22 2019 at 13:12)</a>:</h4>
<p>Yeah, you have a point</p>



<a name="178753896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178753896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178753896">(Oct 22 2019 at 13:13)</a>:</h4>
<p>In isolation, this is the best: <a href="https://godbolt.org/z/iysHeL" target="_blank" title="https://godbolt.org/z/iysHeL">https://godbolt.org/z/iysHeL</a></p>



<a name="178753915"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178753915" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178753915">(Oct 22 2019 at 13:13)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">pub</span><span class="w"> </span><span class="k">unsafe</span><span class="w"> </span><span class="k">fn</span> <span class="nf">m32x2_allSSE</span><span class="p">(</span><span class="n">x</span>: <span class="nc">m32x2</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span>: <span class="kt">u64</span> <span class="o">=</span><span class="w"> </span><span class="n">transmute</span><span class="p">(</span><span class="n">x</span><span class="p">);</span><span class="w"></span>
<span class="w">    </span><span class="n">x</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="kt">u64</span>::<span class="n">max_value</span><span class="p">()</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="178753940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178753940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178753940">(Oct 22 2019 at 13:13)</a>:</h4>
<p>lol that's fair</p>



<a name="178753961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178753961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178753961">(Oct 22 2019 at 13:13)</a>:</h4>
<p>I think <code>packed_simd</code> does that in many cases</p>



<a name="178754004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754004">(Oct 22 2019 at 13:14)</a>:</h4>
<p>but also particularly misleading in isolation since it doesn't look so great when the mask is produced from SSE instructions</p>



<a name="178754037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754037">(Oct 22 2019 at 13:14)</a>:</h4>
<p><a href="https://github.com/rust-lang-nursery/packed_simd/blob/master/src/codegen/reductions/mask/fallback_impl.rs#L66" target="_blank" title="https://github.com/rust-lang-nursery/packed_simd/blob/master/src/codegen/reductions/mask/fallback_impl.rs#L66">https://github.com/rust-lang-nursery/packed_simd/blob/master/src/codegen/reductions/mask/fallback_impl.rs#L66</a></p>



<a name="178754080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754080">(Oct 22 2019 at 13:15)</a>:</h4>
<p>IIRC in some targets and for some vectors LLVM was able to generate quite good code for that, when used in larger examples.</p>



<a name="178754105"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754105" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754105">(Oct 22 2019 at 13:15)</a>:</h4>
<p>But there were also cases where it wasn't due to a variety of llvm bugs, and then workarounds were introduced</p>



<a name="178754132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754132">(Oct 22 2019 at 13:15)</a>:</h4>
<p><a href="https://github.com/rust-lang-nursery/packed_simd/blob/master/src/codegen/reductions/mask/x86/sse.rs#L51" target="_blank" title="https://github.com/rust-lang-nursery/packed_simd/blob/master/src/codegen/reductions/mask/x86/sse.rs#L51">https://github.com/rust-lang-nursery/packed_simd/blob/master/src/codegen/reductions/mask/x86/sse.rs#L51</a></p>



<a name="178754140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754140">(Oct 22 2019 at 13:15)</a>:</h4>
<p>Anyway, I suspect that for the actual application/benchmark, some higher level algorithmic changes could allow doing everything in SSE registers directly (loads, compares, and reductions).</p>



<a name="178754275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754275">(Oct 22 2019 at 13:16)</a>:</h4>
<p>I think that not dealing with EMMS is worth a performance hit</p>



<a name="178754288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754288">(Oct 22 2019 at 13:17)</a>:</h4>
<p>That too, but best if there's no performance hit to begin with</p>



<a name="178754291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754291">(Oct 22 2019 at 13:17)</a>:</h4>
<p>and if that is not acceptable, then we'd just use inline assembly instead</p>



<a name="178754317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754317">(Oct 22 2019 at 13:17)</a>:</h4>
<p>but <code>packed_simd</code> should not use MMX registers anywhere</p>



<a name="178754323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754323">(Oct 22 2019 at 13:17)</a>:</h4>
<p>You mean inline asm for the any/all/none intrinsics?</p>



<a name="178754334"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754334" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754334">(Oct 22 2019 at 13:17)</a>:</h4>
<p>not in the general case, but as a workaround over an LLVM bug</p>



<a name="178754360"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754360" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754360">(Oct 22 2019 at 13:17)</a>:</h4>
<p>all that parent module is workarounds over llvm bugs</p>



<a name="178754438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754438">(Oct 22 2019 at 13:18)</a>:</h4>
<p>Sure but still, such small inline asm seems like it would likely cause more performance problems (blocking combines, blinding regalloc and scheduling) than it's worth</p>



<a name="178754445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754445">(Oct 22 2019 at 13:18)</a>:</h4>
<p>But <em>shrug</em> try it if you have to</p>



<a name="178754452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754452">(Oct 22 2019 at 13:18)</a>:</h4>
<p>I would love to be able to kill <code>__m64</code></p>



<a name="178754888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178754888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178754888">(Oct 22 2019 at 13:23)</a>:</h4>
<p>I think there is an open issue to at least restrict that, but yeah, should be killed</p>



<a name="178755093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178755093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178755093">(Oct 22 2019 at 13:25)</a>:</h4>
<p>Restrict how?</p>



<a name="178755149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178755149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178755149">(Oct 22 2019 at 13:26)</a>:</h4>
<p>For that matter, restrict what?</p>



<a name="178755761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178755761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178755761">(Oct 22 2019 at 13:33)</a>:</h4>
<p>To restrict <code>__m64</code> to be the only SIMD type that lowers to <code>x86_mmx</code></p>



<a name="178755849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178755849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178755849">(Oct 22 2019 at 13:34)</a>:</h4>
<p>right now, any <code>#[repr(simd)]</code> ADT containing a single field, with type <code>i64</code>, is lowered to <code>x86_mmx</code></p>



<a name="178755942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178755942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178755942">(Oct 22 2019 at 13:35)</a>:</h4>
<p>Ah</p>



<a name="178756014"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178756014" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178756014">(Oct 22 2019 at 13:36)</a>:</h4>
<p>I'd be happier if that were restricted further, e.g., to types with a <code>#[repr(simd(x86_mmx))]</code> attribute or similar. </p>
<p>I wouldn't oppose just completely removing all support for <code>x86_mmx</code>, and either removing the MMX intrinsics, or implementing them on top of SSE2.</p>



<a name="178756022"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178756022" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178756022">(Oct 22 2019 at 13:36)</a>:</h4>
<p>But I'd rather just remove them</p>



<a name="178756042"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178756042" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178756042">(Oct 22 2019 at 13:36)</a>:</h4>
<p>They are not in the path towards stabilization anyways</p>



<a name="178756051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178756051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178756051">(Oct 22 2019 at 13:36)</a>:</h4>
<p>yes pls</p>



<a name="178756063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178756063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178756063">(Oct 22 2019 at 13:36)</a>:</h4>
<p>And MMX causes more trouble than it solves, those who need it can use inline assembly instead if they so desire</p>



<a name="178756073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178756073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178756073">(Oct 22 2019 at 13:37)</a>:</h4>
<p>and that's just as unstable as the MMX intrinsics</p>



<a name="178756091"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178756091" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178756091">(Oct 22 2019 at 13:37)</a>:</h4>
<p>or just leave the cursed algorithm in C land and call it through FFI</p>



<a name="178756376"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178756376" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178756376">(Oct 22 2019 at 13:39)</a>:</h4>
<p><a href="https://github.com/rust-lang/stdarch/issues/823" target="_blank" title="https://github.com/rust-lang/stdarch/issues/823">https://github.com/rust-lang/stdarch/issues/823</a></p>



<a name="178757328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178757328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178757328">(Oct 22 2019 at 13:48)</a>:</h4>
<p>So in the end we should close <a href="https://github.com/rust-lang/rust/issues/53254" target="_blank" title="https://github.com/rust-lang/rust/issues/53254">https://github.com/rust-lang/rust/issues/53254</a>, fix packed_simd and nuke mmx from orbit?</p>



<a name="178757408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178757408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178757408">(Oct 22 2019 at 13:48)</a>:</h4>
<p>Different order (fix packed_simd, then close issue) but yes that would be my preferred approach</p>



<a name="178764240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178764240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178764240">(Oct 22 2019 at 15:02)</a>:</h4>
<p>I think the issue can be closed, the packed_simd bug is a different bug, only tangentially related to the issue</p>



<a name="178773541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178773541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178773541">(Oct 22 2019 at 16:47)</a>:</h4>
<p>Thank you everyone for the investigation and sorry for cluttering this wg.</p>



<a name="178933326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178933326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178933326">(Oct 24 2019 at 09:05)</a>:</h4>
<p><span class="user-mention" data-user-id="119581">@Mateusz Mikuła</span> thank you for all your work reducing the examples and tracking this down too!</p>



<a name="178933377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/187780-t-compiler/wg-llvm/topic/NaNs%20in%20windows-gnu%20float%20arthitmetic/near/178933377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/187780-t-compiler/wg-llvm/topic/NaNs.20in.20windows-gnu.20float.20arthitmetic.html#178933377">(Oct 24 2019 at 09:06)</a>:</h4>
<p>That <code>packed_simd</code> bug has been opened for a long time, and now we can finally close it!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>